<?php
include('inc_head.php');
$id=$wu->request_int('id');
$tag=$wu->request_string('tag');
if(!$tag) 		die('参数有误');
$data=array('Name'=>'','CatalogID'=>0,'Description'=>'','Thumb'=>'');
if($id){
	$data=$db->fetch_row("select * from tproductgoods where ID=$id");	
}
if($wu->request_string("act")=='save'){
	if($id){
		$db->update('tproductgoods',"Name='".$wu->request_string('Name')."', CatalogID=".$wu->request_int('CatalogID').", Description='".$wu->request_string('Description')."', Thumb='".$wu->request_string("Thumb")."'","ID=$id");
		$wu->redirect('编辑成功','product_list.php?tag='.$tag);
	}else{
		$db->insert('tproductgoods','Name,CatalogID,Description,Thumb,ExTags',"'".$wu->request_string('Name')."',".$wu->request_int('CatalogID').", '".$wu->request_string('Description')."','".$wu->request_string("Thumb")."','$tag'");
		$wu->redirect('新增成功','product_list.php?tag='.$tag);
	}
}
?>
<form action="#" method="post" >
    <h1>编辑产品</h1>
<table cellpadding="0" cellspacing="0">
                名称</td><td>
                <input type="text" name="Name" size="12" value="<?php echo $data['Name']; ?>" /><span
                    class="help-block">长度不超过15个汉字.</span></td></tr>
        <tr><td>
                所属分类</td><td>
                <select name="CatalogID"><?php echo $biz->get_generaltree($data['CatalogID'],'tgeneralcatalog',$tag); ?></select>
            </td></tr>
        <tr><td>
                配图：</td><td>
                <?php echo get_fileinput('Thumb',$wu->path_reset($data['Thumb'],'../../')); ?>
            </td></tr>
        <tr><td>
                内容</td><td>
            	<textarea name="Description" cols="120" rows="15" class="editor"><?php echo $data['Description']; ?></textarea>
            </td></tr>
        <tr><td>
                <input type="submit" value="保存" />
                <input type="reset" class="btn" value="重置" />
            	<input type="hidden" name="act" value="save" />
            </td></tr>
    </fieldset>
</form>
<?php include('inc_foot.php'); ?>